<?
$params[sid]=$sid;
$params[action]="emails";
$url_add="$baseURL/?".encode_params($params);

$params[action]="del_emails";
$url_del="$baseURL/?".encode_params($params);

$params[action]="chng_pass_mailbox";
$url_pass="$baseURL/?".encode_params($params);

$domain=list_reseller_domains($id,'array');
$func[function_name]="get_emails";
$func[params][domain]=$domain;

include_once('../hosting_connect/call.php');
$res=call_remote_method($func);
foreach($domain as $d){
	$domains.="<option value='$d'>$d</option>";
}
if(is_array($res)){
	foreach($res as $email){
		$list.="<tr><td><input type='checkbox' name='emails[]' value='$email'></td><td>$email</td></tr>";
	}
}else $list="<tr><td colspan=2>" . translate('no_emails') . "</td></tr>";
?> 
<table>
<td width="396" cellspacing=0>
  <tr> 
    <td colspan=2><font class="text"><b><?=translate('email_manager');?></b><br>
      <br>
      <?=translate('email_manager_desc');?> </font></td>
  </tr>
</td>
</table>
<br>
<?
	if ($errorMsg) {
	include_once('errorMsg.html');
	}
	if ($okMsg) {
	include_once('okMsg.html');
	}
	else{
	}
?>
<br>
<TABLE  class='bTable' cellspacing=0>
<FORM METHOD='POST' ACTION="<?echo $url_add?>">
<tr>
<th colspan=3 align='left'><?=translate('add_alias');?>:</th>
</tr>
<TR>
	<TD><?=translate('alias');?>:</TD>
	<TD><INPUT TYPE="text" NAME="email"></TD>
	<TD>@<SELECT NAME="domain"><?echo $domains?></SELECT></TD>
</TR>
<TR>
	<TD colspan=3 align=left> <INPUT TYPE="submit" value="<?=translate('create');?>"></TD>
</TR>
</FORM>
</TABLE>
<br><br>

<form action='<?echo $url_del?>' method='POST'>
<table class='bTable' cellspacing=0>
<tr><th colspan=2 align='left'><?=translate('del_emails');?>:</th></tr>
<?echo $list;?>

<tr><td colspan=5 align='left'>
        <input type='submit' value='<?=translate('del_selected');?>'>
      </tr>
</table>
</form>
<br><br>

<form action='<?echo $url_pass?>' method='POST'>
<table class='bTable' cellspacing=0>
	<tr><th colspan=2 align='left'><?=translate('change_pass');?>:</th></tr>
	<tr><td><?=translate('mailbox');?>:</td><td><select name=mailbox ><?=$domains?></select></td></tr>
	<tr><td><?=translate('password');?>: </td><td><input type ='password' name='pass'></td></tr>
	<tr><td><?=translate('re_password');?>: </td><td><input type ='password' name='repass'></td></tr>
	<tr><td colspan=2 align='left'><input type='submit' value='<?=translate('change_pass');?>'> </td></tr>
</table>

</form>
